<?php 
function GetProducts()
{
        $conn = getConnection();
        $sql = 'SELECT Prod.*, EMan.Manufacturer as Manufacturer, EPCond.Value as Condit, EPType.Value as Sport_Type, ESport.Value as Product_Type '
        		. 	'FROM EcsProducts Prod '
        		.	'JOIN EcsManufacturers EMan ON Prod.Manufacturer_ID = EMan.ID '
        		.	'JOIN EcsProductCondition EPCond ON Prod.ProductCond_ID = EPCond.ID	'
        		. 	'JOIN EcsProductType EPType ON Prod.ProductType_ID = EPType.ID	'
        		.	'JOIN EcsSportType ESport ON Prod.SportType_ID = ESport.ID ';
        		
        $result = $conn->query($sql);
        return $result;
}
//THE WORD "Condition" is not allowed in a MySQL SELECT STATEMENT!!!  Who knew?  Not me, but I do now!
function GetProduct($id)
{
		$conn = getConnection();
		$sql = 'SELECT Prod.ProductName, Prod.SalePrice, EMan.Manufacturer as Manufacturer, EPCond.Value as Condit, EPType.Value as Sport_Type, ESport.Value as Product_Type '
        		. 	'FROM EcsProducts Prod '
        		.	'JOIN EcsManufacturers EMan ON Prod.Manufacturer_ID = EMan.ID '
        		.	'JOIN EcsProductCondition EPCond ON Prod.ProductCond_ID = EPCond.ID	'
        		. 	'JOIN EcsProductType EPType ON Prod.ProductType_ID = EPType.ID	'
        		.	'JOIN EcsSportType ESport ON Prod.SportType_ID = ESport.ID '
        		.	"WHERE Prod.ID=$id";
        $result = $conn->query($sql);
        $rs = $result->fetch_assoc();
        $conn->close();
        return $rs;
}
